/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.edu.ifal.crazypizza.gui;

import javax.swing.JOptionPane;

/**
 *
 * @author Lucas
 */
public class FrmBuscaFuncionarios extends javax.swing.JFrame {

    /**
     * Creates new form FrmBuscaFuncionarios
     */
    public FrmBuscaFuncionarios() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlBusca = new javax.swing.JPanel();
        ComboBusca = new javax.swing.JComboBox();
        txtBusca = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblBusca = new javax.swing.JTable();
        btnBuscar1 = new javax.swing.JButton();
        btnSair1 = new javax.swing.JButton();
        BarraCarregar = new javax.swing.JProgressBar();
        lblMensagem = new javax.swing.JLabel();
        lblImagem = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("BUSCA FUNCIONÁRIOS");
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        pnlBusca.setBackground(new java.awt.Color(255, 255, 204));
        pnlBusca.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "BUSCA FUNCIONÁRIOS", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Comic Sans MS", 0, 24), new java.awt.Color(255, 0, 0))); // NOI18N

        ComboBusca.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ComboBusca.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Nome", "CPF", "Numero de Cadastro" }));

        tblBusca.setFont(new java.awt.Font("Comic Sans MS", 0, 14)); // NOI18N
        tblBusca.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Código Funcionário", "Nome", "CPF", "Telefone"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane2.setViewportView(tblBusca);

        btnBuscar1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnBuscar1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/edu/ifal/crazypizza/imagens/Icone Pesquisar.png"))); // NOI18N
        btnBuscar1.setText("BUSCAR");
        btnBuscar1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                btnBuscar1btnBuscarStateChanged(evt);
            }
        });
        btnBuscar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscar1btnBuscarActionPerformed(evt);
            }
        });

        btnSair1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnSair1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/edu/ifal/crazypizza/imagens/Botao - Cancelar.png"))); // NOI18N
        btnSair1.setText("SAIR");
        btnSair1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSair1btnSairActionPerformed(evt);
            }
        });

        BarraCarregar.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        BarraCarregar.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                BarraCarregarBarraStateChanged(evt);
            }
        });
        BarraCarregar.addAncestorListener(new javax.swing.event.AncestorListener() {
            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
            }
            public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
                BarraCarregarBarraAncestorAdded(evt);
            }
            public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
            }
        });

        javax.swing.GroupLayout pnlBuscaLayout = new javax.swing.GroupLayout(pnlBusca);
        pnlBusca.setLayout(pnlBuscaLayout);
        pnlBuscaLayout.setHorizontalGroup(
            pnlBuscaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBuscaLayout.createSequentialGroup()
                .addGroup(pnlBuscaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlBuscaLayout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnBuscar1)
                        .addGap(72, 72, 72)
                        .addComponent(btnSair1, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(58, 58, 58))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlBuscaLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(pnlBuscaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlBuscaLayout.createSequentialGroup()
                                .addComponent(lblMensagem, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(117, 117, 117)
                                .addComponent(BarraCarregar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlBuscaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(pnlBuscaLayout.createSequentialGroup()
                                    .addComponent(ComboBusca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(txtBusca, javax.swing.GroupLayout.PREFERRED_SIZE, 299, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 517, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addGap(1814, 1814, 1814))
        );
        pnlBuscaLayout.setVerticalGroup(
            pnlBuscaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBuscaLayout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(pnlBuscaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ComboBusca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtBusca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(43, 43, 43)
                .addGroup(pnlBuscaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnSair1)
                    .addComponent(btnBuscar1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 58, Short.MAX_VALUE)
                .addGroup(pnlBuscaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(BarraCarregar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblMensagem, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        getContentPane().add(pnlBusca, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 200, 570, 390));

        lblImagem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/edu/ifal/crazypizza/imagens/Tela Login.jpg"))); // NOI18N
        getContentPane().add(lblImagem, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 10, -1, -1));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnBuscar1btnBuscarStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_btnBuscar1btnBuscarStateChanged

        // TODO add your handling code here:
    }//GEN-LAST:event_btnBuscar1btnBuscarStateChanged

    private void btnBuscar1btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscar1btnBuscarActionPerformed
     new Thread(new FrmBuscaFuncionarios.Carregar()).start();

        // TODO add your handling code here:
    }//GEN-LAST:event_btnBuscar1btnBuscarActionPerformed

    private void btnSair1btnSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSair1btnSairActionPerformed
    this.dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_btnSair1btnSairActionPerformed

    private void BarraCarregarBarraStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_BarraCarregarBarraStateChanged

        // TODO add your handling code here:
    }//GEN-LAST:event_BarraCarregarBarraStateChanged

    private void BarraCarregarBarraAncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_BarraCarregarBarraAncestorAdded

    }//GEN-LAST:event_BarraCarregarBarraAncestorAdded

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrmBuscaFuncionarios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrmBuscaFuncionarios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrmBuscaFuncionarios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrmBuscaFuncionarios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FrmBuscaFuncionarios().setVisible(true);
            }
        });
    }
     
    public class Carregar implements Runnable{
        private Object Mensagem;

        @Override
        public void run() {
            for(int i=0;i<101;i++){
                
                try{
                    Thread.sleep(80);
                    BarraCarregar.setValue(i);
                    if (BarraCarregar.getValue() <= 20){
                lblMensagem.setText("Efetuando Busca");
                
            }else if(BarraCarregar.getValue()<=40){
                lblMensagem.setText("Carregando Banco de dados...");
            }else if(BarraCarregar.getValue()<=70){
                lblMensagem.setText("Carregando sistema...");
            }else if(BarraCarregar.getValue()>99){
               lblMensagem.setText("Concluido!");
                JOptionPane.showMessageDialog(null, "Busca efetuada Com Sucesso !");
                System.exit(0);
            }
                    
            
                }catch(Exception e){
                    
                }
            
            }
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JProgressBar BarraCarregar;
    private javax.swing.JComboBox ComboBusca;
    private javax.swing.JButton btnBuscar1;
    private javax.swing.JButton btnSair1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lblImagem;
    private javax.swing.JLabel lblMensagem;
    private javax.swing.JPanel pnlBusca;
    private javax.swing.JTable tblBusca;
    private javax.swing.JTextField txtBusca;
    // End of variables declaration//GEN-END:variables
}
